/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 adv_map_point.h

	$Header: /heroes4/adv_map_point.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( ADV_MAP_POINT_H_INCLUDED )
#define ADV_MAP_POINT_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "map_point.h"

// map point with row, column, level, and whether item is on a bridge
struct t_adv_map_point : public t_level_map_point_2d
{
	bool on_bridge;

	// Constructors
	t_adv_map_point();
	t_adv_map_point( t_map_point_2d const & point_2d, int level_arg, bool on_bridge );
	t_adv_map_point( t_level_map_point_2d const & point, bool on_bridge );
	t_adv_map_point( int row_arg, int column_arg, int level_arg, bool on_bridge );

	// Operators
	t_adv_map_point & operator+=( t_map_point_2d const & right );
	t_adv_map_point & operator+=( t_level_map_point_2d const & right );
	t_adv_map_point & operator-=( t_map_point_2d const & right );
	t_adv_map_point & operator-=( t_level_map_point_2d const & right );
};

inline t_adv_map_point::t_adv_map_point()
{
}

inline t_adv_map_point::t_adv_map_point( t_map_point_2d const & point_2d, 
										 int level_arg, bool on_bridge_arg )
					  : t_level_map_point_2d( point_2d, level_arg )
{
	on_bridge = on_bridge_arg;
}

inline t_adv_map_point::t_adv_map_point( t_level_map_point_2d const & point, 
										 bool on_bridge_arg )
					  : t_level_map_point_2d( point )
{
	on_bridge = on_bridge_arg;
}

inline t_adv_map_point::t_adv_map_point( int row_arg, int column_arg, int level_arg, 
										 bool on_bridge_arg )
{
	row = row_arg;
	column = column_arg;
	level = level_arg;
	on_bridge = on_bridge_arg;
}

// Operators
inline t_adv_map_point & t_adv_map_point::operator+=( t_map_point_2d const & right )
{
	t_map_point_2d::operator+=( right );
	return *this;
}

inline t_adv_map_point & t_adv_map_point::operator+=( t_level_map_point_2d const & right )
{
	t_level_map_point_2d::operator += ( right );
	return *this;
}

inline t_adv_map_point & t_adv_map_point::operator-=( t_map_point_2d const & right )
{
	t_map_point_2d::operator -= ( right );
	return *this;
}

inline t_adv_map_point & t_adv_map_point::operator-=( t_level_map_point_2d const & right )
{
	t_level_map_point_2d::operator -= ( right );
	return *this;
}

// ---------------------------------------------------------------
// inline free functions for t_adv_map_point
// ---------------------------------------------------------------
inline bool operator==( t_adv_map_point const & left, t_adv_map_point const & right )
{
	return	left.row == right.row && left.column == right.column
		 && left.level == right.level && left.on_bridge == right.on_bridge;
}

inline bool operator!=( t_adv_map_point const & left, t_adv_map_point const & right )
{
	return !( left == right );
}

inline t_adv_map_point operator+( t_adv_map_point const &		left, 
								  t_level_map_point_2d const &	right )
{
	t_adv_map_point result( left );
	result += right;
	return result;
}

inline t_adv_map_point operator+( t_level_map_point_2d const&	left, 
								  t_adv_map_point const &		right )
{
	t_adv_map_point result( right );
	result += left;
	return result;
}


inline t_adv_map_point operator+( t_adv_map_point const &	left,
								  t_map_point_2d const &	right )
{
	t_adv_map_point result( left );
	result += right;
	return result;
}

inline t_adv_map_point operator+( t_map_point_2d const & left, t_adv_map_point const & right )
{
	return right + left;
}

inline t_adv_map_point operator-( t_adv_map_point const&		left, 
								  t_level_map_point_2d const&	right )
{
	t_adv_map_point result( left );
	result -= right;
	return result;
}

inline t_adv_map_point operator-( t_adv_map_point const&	left, 
								  t_map_point_2d const&		right )
{
	t_adv_map_point result( left );
	result -= right;
	return result;
}

inline std::streambuf & operator<<( std::streambuf & stream, t_adv_map_point const & point )
{
	put< t_int32 >( stream, point.row );
	put< t_int32 >( stream, point.column );
	put< t_int32 >( stream, point.level );
	put< bool >( stream, point.on_bridge );
	return stream;
}

inline std::streambuf & operator>>( std::streambuf & stream, t_adv_map_point & point )
{
	point.row		= get<t_int32>( stream );
	point.column	= get<t_int32>( stream );
	point.level		= get<t_int32>(stream );
	point.on_bridge = get<bool>(stream);
	return stream;
}


#endif //  ADV_MAP_POINT_H_INCLUDED